<!doctype html>
<html lang="en-us">

<head>
  <meta charset="utf-8">
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>Simple</title>
</head>

<body>
  <div>
    <button class="mybutton">运行我的程序</button>
  </div>
  <hr />
  <script type='text/javascript'>
    var Module = {
      preRun: [],
      postRun: [],
      print: (function () {
        return function (text) {
          console.log(text);
        };
      })(),
      printErr: function (text) {
        console.error(text);
      },
      // canvas: (function () {
      //   var canvas = document.getElementById('canvas');

      //   // As a default initial behavior, pop up an alert when webgl context is lost. To make your
      //   // application robust, you may want to override this behavior before shipping!
      //   // See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
      //   canvas.addEventListener("webglcontextlost", function (e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);

      //   return canvas;
      // })(),
      // setStatus: function (text) {
      //   if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
      //   if (text === Module.setStatus.last.text) return;
      //   var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
      //   var now = Date.now();
      //   if (m && now - Module.setStatus.last.time < 30) return; // if this is a progress update, skip it if too soon
      //   Module.setStatus.last.time = now;
      //   Module.setStatus.last.text = text;
      //   if (m) {
      //     text = m[1];
      //     progressElement.value = parseInt(m[2]) * 100;
      //     progressElement.max = parseInt(m[4]) * 100;
      //     progressElement.hidden = false;
      //     spinnerElement.hidden = false;
      //   } else {
      //     progressElement.value = null;
      //     progressElement.max = null;
      //     progressElement.hidden = true;
      //     if (!text) spinnerElement.hidden = true;
      //   }
      //   statusElement.innerHTML = text;
      // },
      // totalDependencies: 0,
      // monitorRunDependencies: function (left) {
      //   this.totalDependencies = Math.max(this.totalDependencies, left);
      //   Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies - left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
      // }
    };
    // Module.setStatus('Downloading...');
    window.onerror = function () {
      // Module.setStatus('Exception thrown, see JavaScript console');
      // spinnerElement.style.display = 'none';
      // Module.setStatus = function (text) {
      //   if (text) Module.printErr('[post-exception status] ' + text);
      // };
    };

    document.querySelector('.mybutton').addEventListener('click', function () {
      // var result = Module.ccall('myFunction', // name of C function 
      //   null, // return type
      //   null, // argument types
      //   null); // arguments
      var result = Module.ccall('add', // name of C function 
        'number', // return type
        ['number', 'number'], // argument types
        [1, 2]); // arguments
      console.log('result', result);
    });
  </script>
  <script async src='./hello_wasm.js'></script>
</body>

</html>